/*
 * Copyright (c) 2006, 2021, webrx.cn All rights reserved.
 *
 */
package cn.webrx;

import java.util.Random;
import java.util.stream.Stream;

/**
 * <p>Project: javaseapp - Stream3a
 * <p>Powered by webrx On 2021-08-23 09:24:39
 * <p>Created by IntelliJ IDEA
 *
 * @author webrx [webrx@126.com]
 * @version 1.0
 * @since 16
 */
public class Stream3a {
    public static void main(String[] args) {
        //数字流 排序
        var smn = Stream.of(1, 0, 5, 2, 20, 9, 7, 3, 90, 50, 6);
        //升序
        //smn.sorted().forEach(e -> System.out.printf("%d ", e));
        //降序
        //smn.sorted((a, b) -> b - a).forEach(e -> System.out.printf("%d ", e));
        //乱序  Collections.shuffle(list);
        
        smn.sorted((a, b) -> {
            int i = 0;
            Random rand = new Random();
            if (rand.nextBoolean()) {
                i = 1;
            } else if (rand.nextBoolean()) {
                i = -1;
            }
            return i;
        }).forEach(System.out::println);

        System.out.println();
        //字符串流排序
        var sms = Stream.of("c", "java", "go", "ruby", "python", "php", "javascript", "sql");
        //sms.sorted().forEach(System.out::println);
        //sms.sorted(Comparator.reverseOrder()).forEach(System.out::println);

        //字符串个数

    }
}
